

ajax({
    url:"http://www.jd.com",
    method:"POST",
    success:function(obj){
        let result = transfrom(obj);
        console.log(result)
    }
})

function ajax(options){
    let defaultOptions = {
        method :"GET",
        dataType:"json"
    }
    for(let attr in defaultOptions ){
        // 以传进来的为主，否则是默认
        defaultOptions[attr] = options[attr] || defaultOptions[attr]

    }
    console.log(defaultOptions);
}

function transfrom(str){
    return JSON.parse(str);
}